home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 97 / CD-ROM 97 / CD-ROM 97.iso / jogos / spherical / Code / Library / input.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-13  |  3.6 KB  |  121 lines

  1.  
  2. // Copyright (C) 2002 by Luigi Pino.  All Rights Reserved.
  3.  
  4. /***************************************************************************/
  5.  
  6. // Button Input
  7. #define        Nothing_Pressed                0
  8. #define        Button_1                            1
  9. #define        Button_2                            2
  10. #define        Button_3                            4
  11. #define        Button_4                            8
  12. #define        Button_5                            16
  13. #define        Button_6                            32
  14. #define        Button_7                            64
  15. #define        Button_8                            128
  16. #define        Button_9                            256
  17.  
  18. // Direction Input
  19. #define        Up                                        0
  20. #define        Down                                    1
  21. #define        Left                                    2
  22. #define        Right                                    3
  23.  
  24. // Input Type
  25. #define        Keyboard_1                        0
  26. #define        Keyboard_2                        1
  27. #define        Joystick_1                        2
  28. #define        Joystick_2                        3
  29. #define        Joystick_3                        4
  30. #define        Joystick_4                        5
  31. #define        Computer                            6
  32. #define        No_User                                7
  33.  
  34. // Joystick naming
  35. #define        ERROR_NOTOEM                    -1
  36.  
  37. /***************************************************************************/
  38.  
  39. class Controller_Class {
  40.     private:
  41.         class Joystick_Class {
  42.             public:
  43.                 Joystick_Class();
  44.                 ~Joystick_Class();
  45.  
  46.                 int                forth_axis;                                                    // Forth axis
  47.                 int                fifth_axis;                                                    // Fifth axis
  48.                 int                sixth_axis;                                                    // Sixth axis
  49.                 int                point_of_view;                                            // Point of view
  50.                 JOYINFOEX    info;                                                                // Tag
  51.             };
  52.  
  53.         class Keyboard_Class {
  54.             public:
  55.                 Keyboard_Class();
  56.                 ~Keyboard_Class();
  57.  
  58.                 void Set_Keys(int b0, int b1, int b2, int b3, int b4, int b5, int b6, int  b7, int b8,
  59.                                             int bup, int bdown, int bleft, int bright);
  60.  
  61.                 int    button_id[9];                                                            // Button id
  62.                 int    direction_id[4];                                                    // Direction id
  63.             };
  64.  
  65.     public:
  66.         Controller_Class();                                                                // Constructor
  67.         ~Controller_Class();                                                            // Deconstructor
  68.  
  69.         void    Clear();                                                                        // Clears button and movement input
  70.         void    Get_Info();                                                                    // Joystick/keyboard button/movement information
  71.  
  72.         Joystick_Class    joystick;                                                    // Joystick input
  73.         Keyboard_Class    keyboard;                                                    // Keyboard input
  74.         float2                    button[9];                                                // \. Amount pressed (x = current interval, y = total interval)
  75.         float2                    direction[4];                                            // /
  76.         int                            user;                                                            // Keyboard, joystick, computer controlled or none
  77. };
  78.  
  79. class Mouse_Class {
  80.     public:
  81.         Mouse_Class();
  82.         ~Mouse_Class();
  83.  
  84.         void    Clear();                                                                        // Clears button and movement input
  85.         void    Get_Info(bool out_of_bounds_reset);                    // Mouse button/movement information
  86.  
  87.         float2    button[3];                                                                // 0 - left, 1 - right, 2 - middle
  88.         float2    change;                                                                        // Change in position
  89.         POINT        current;                                                                    // New position
  90.         POINT        last;                                                                            // Old position
  91. };
  92.  
  93. /***************************************************************************/
  94.  
  95. class Timing_Class {
  96.     public:
  97.         Timing_Class();                                                                        // Constructor
  98.         ~Timing_Class();                                                                    // Deconstructor
  99.  
  100.         unsigned    Get_CPU_Cycle();
  101.         float            Get_Frequency();
  102.         float            Get_Scale();
  103.         void            Update();
  104.  
  105.     private:
  106.         void            Calculate_Frequency();
  107.  
  108.         bool            precision_testing;                                            // Which timing function to use
  109.         float            frequency;                                                            // MHz of computer
  110.         float            scale;                                                                    // Time interval between cycle calls
  111.         unsigned    cycle_end;                                                            // End of cycle call
  112.         unsigned    cycle_start;                                                        // Start of cycle call
  113. };
  114.  
  115. /***************************************************************************/
  116.  
  117. MMRESULT    Get_Joystick_Name(UINT id, TCHAR * pszName);
  118.  
  119. bool            Interval(float2 *key, float interval);
  120.  
  121. /***************************************************************************/